# -*- coding: utf-8 -*-

"""
controller for task
"""

from framework.controller import Controller
import tornado.httpclient
import tornado.web

class TestCtrl(Controller):
    """task list"""
    def __init__(self, application, request, **kwargs):
        """init"""
        super(TestCtrl, self).__init__(application, request, **kwargs)

    @tornado.web.asynchronous
    def get(self):
        ak = 'sjiqZ9MndXqeqI4a39TO5IQUf2i2GC7F'
        location = '广州'
        url = 'http://api.map.baidu.com/geocoder/v2/?address=%s&output=json&ak=%s' % (location, ak)
        c = tornado.httpclient.AsyncHTTPClient()
        c.fetch(url, self.on_fetch)

    def on_fetch(self, res):
        print res.body
        self.write_error(404)